import { Body, Controller, Get, Post, Query, SetMetadata } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PermissionService } from './permission.service';
import { CreatePermissionDto, DeletePermissionDto, FindManyPermissionDto, UpdatePermissionDto } from '../dto/permission.dto';

@ApiTags('权限管理')

@Controller('permission')
@SetMetadata('require-permission', ['superAdmin'])
export class PermissionController {
    constructor(private readonly permissionService: PermissionService) { }

    @Post("create")
    create(@Body() cd: CreatePermissionDto) {
        return this.permissionService.create(cd);
    }

    @Post("delete")
    delete(@Body() dd: DeletePermissionDto) {
        return this.permissionService.delete(dd)
    }

    @Post("update")
    update(@Body() ud: UpdatePermissionDto) {
        return this.permissionService.update(ud)
    }

    @Get("findMany")
    findMany(@Query() fmd: FindManyPermissionDto) {
        return this.permissionService.findMany(fmd)
    }
}
